[VPEX][5a] Add local-env package-manager interface, detection, and preflight#5850
Merged
Conversation
Collaborator
Integration test reportCommit: f24c320
8 interesting tests: 4 SKIP, 3 RECOVERED, 1 KNOWN
Top 6 slowest tests (at least 2 minutes):
|
Split from the pipeline layer so the PackageManager seam (implemented by the uv backend in a later PR), manager detection, and the writability preflight land as a small, independently reviewable unit. - pkgmanager.go: the PackageManager interface the pipeline provisions through. - detect.go: uv-vs-not-uv detection (biased toward uv, whose native project file is the pyproject.toml this command drives), the non-blaming guidance message for unsupported managers, and the ensureWritable preflight. Co-authored-by: Isaac
rugpanov
force-pushed
the
dbconnect/05a-pkgmanager
branch
from
July 8, 2026 14:44
cb166cb to
f24c320
Compare
anton-107
approved these changes
Jul 9, 2026
anton-107
left a comment
Contributor
There was a problem hiding this comment.
Approving. Clean leaf of the stack: detectManager is pure-fs with no telemetry (matches its doc), the uv-bias logic is well-reasoned and fully table-tested, and ensureWritable + managerGuidance are covered. PackageManager interface is small and well-documented (the PostProvision/pip-seeding comment captures a real VS Code quirk). No findings.
Collaborator
Integration test reportCommit: f7c9cee
37 interesting tests: 17 FAIL, 15 flaky, 2 RECOVERED, 2 SKIP, 1 KNOWN
Top 50 slowest tests (at least 2 minutes):
|
bradleyjamrozik-origindigital
pushed a commit
to Origin-Digital-LLC/databricks-cli
that referenced
this pull request
Jul 13, 2026
…5851) ## Why - The earlier layers (resolve / fetch / merge) need an orchestrator that runs them in order, reports structured per-phase status, and provisions the environment — without mutating disk in `--check` dry-run mode. - This is the core half of the split described in databricks#5850: the six-phase pipeline itself, stacked on the package-manager/detection layer. ## What - **`pipeline.go`** — the six-phase orchestrator (`preflight → resolve → fetch → merge → provision → validate`). It records per-phase status into `Result` and returns typed `PipelineError`s carrying `FailurePhase` and `DiskMutated`. Under `--check` it computes and reports the plan (with a diff) and performs no writes, skipping the writability probe and package-manager availability (neither is needed to compute the plan). - The merge base is the **live `pyproject.toml`**. `MergeManaged` rewrites only the three managed regions and is idempotent on its own output, so a re-run preserves edits the user made between syncs. The `.bak` is a one-time safety copy of the pre-sync original (created only when none exists, on the first sync of an existing project); an unreadable or unstattable existing file fails loudly rather than being misread as greenfield and overwritten. - `constraints-only` stops *managing* the databricks-connect pin rather than removing it: a greenfield project renders `dev = []` (no databricks-connect), and an existing project that already pins databricks-connect keeps its pin untouched. ## Testing strategy - End-to-end unit tests of the phase machine against a fake `PackageManager` + stub compute + `httptest` server: `--check` mutates nothing (even on a read-only dir / without a package manager) and reports a plan that matches a real re-run (no spurious backup, empty diff when idempotent), greenfield vs. existing, the merge basing on the live file so between-sync edits survive, backup safety on unreadable/unstattable files, constraints-only behavior, preflight exits (`E_MANAGER_UNSUPPORTED` / `E_UV_MISSING`), and phase/error attribution (`pipeline_test.go`). - Gates: `go build`, `go test`, `golangci-lint` (0 issues), `deadcode`, `gofmt` — all green. --- ## About this stack **Review bottom-up.** This PR targets databricks#5850 as its base, so its diff shows only the pipeline layer. This PR and databricks#5850 together supersede databricks#5828. This pull request and its description were written by Isaac.
This was referenced Jul 14, 2026
Draft
swearyangupta
pushed a commit
to swearyangupta/cli
that referenced
this pull request
Jul 17, 2026
…ks#5832) ## Why - The engine needs a real `PackageManager` implementation (uv) and a CLI entry point so a user can actually run the feature. - Wiring it in while keeping it `Hidden` lets the command be dogfooded and exercised by acceptance tests without becoming user-visible until the stack is complete. - This is the first layer reachable from `main`, so it also makes the whole `libs/localenv` package live for the `deadcode` checker. ## What - **`libs/localenv/uv.go`** — the uv implementation of `PackageManager`: discover/install uv, install the Python minor, `uv sync`, seed pip into the venv, validate; plus the `pip.conf` → `UV_INDEX_URL` bridge for Databricks-managed machines. - **`cmd/localenv/`** — the command tree matching `local-env python sync`: a `local-env` group (`Hidden: true`), a `python` subgroup, and the `sync` verb. Parent nodes use `root.ReportUnknownSubcommand`; `sync` uses `cobra.NoArgs`, resolves flags/bundle target, builds the `Pipeline` with the uv manager, and renders text or `--json`. All Cobra `Use` values + the `--json` command field come from the `libs/localenv` constants. - **`cmd/cmd.go`** — registers the group. ## Testing strategy - Unit tests for uv helper logic (discovery, `pip.conf` index-url, arg builders, stderr surfacing) (`uv_test.go`). - Runtime smoke test of the hidden 3-level command: absent from top-level help; help works at each level; unknown subcommand exits non-zero; bare group shows help; flags + mutual-exclusion + `NoArgs` behave. - Gates: `go build ./...`, `go test`, `golangci-lint`, `deadcode` (whole tree, no pragmas), `gofmt` — all green. - `cmd/localenv/` unit tests are intentionally deferred to the acceptance PR (databricks#5833), per the repo convention that user-visible CLI output is covered by acceptance tests. --- ## About this stack This is one of a series of small, stacked PRs that together add the `databricks local-env python sync` command — it provisions a local Python environment (Python version, `databricks-connect` pin, and dependency constraints) matched to a selected Databricks compute target. The work was split from one large branch into single-concern layers so each is independently reviewable; the command is kept hidden until the final PR so nothing is user-visible mid-stack. **Review bottom-up.** Each PR targets the previous one as its base branch (this PR targets `main`), so its diff shows only that layer. Layers 1–5 have merged; the original layer-5 PR (databricks#5828) was split into 5a/5b/5c during review. | # | PR | What | Status | |---|----|------|--------| | 1 | databricks#5823 | foundation: result types + env-key mapping | merged | | 2 | databricks#5824 | compute-target resolution | merged | | 3 | databricks#5826 | constraint fetch + offline cache | merged | | 4 | databricks#5827 | formatting-preserving pyproject.toml merge | merged | | 5a | databricks#5850 | package-manager interface + detection | merged | | 5b | databricks#5851 | six-phase pipeline orchestrator | merged | | 5c | databricks#5854 | --check cache purity, greenfield name, dbc insertion | merged | | 6 | **databricks#5832 ← you are here** | uv backend + CLI command (registered hidden) | | | 7 | databricks#5833 | acceptance tests | | | 8 | databricks#5835 | unveil (unhide + help + changelog) | | This pull request and its description were written by Isaac.
swearyangupta
pushed a commit
to swearyangupta/cli
that referenced
this pull request
Jul 17, 2026
## Why - The command's user-visible behavior — text and `--json` output, and every error path — needs end-to-end coverage against the real CLI. - `cmd/localenv/` carries no unit tests by design, so acceptance tests are where that surface is verified (repo convention: user-visible CLI output is covered by acceptance tests). ## What - **`acceptance/localenv/`** — 9 scenarios driven through the (hidden) command against the in-process fake server: `help` (three-level tree), `no-target` (`E_NO_TARGET`), `flag-conflict` (Cobra mutual-exclusion), `manager-unsupported` (conda project → clean P1 exit), `env-unsupported` (404 → `E_ENV_UNSUPPORTED` at fetch), `json-error` (`--output json` error object), `serverless-check` (dry-run plan), `serverless-json` (`--json` plan), and `constraints-only`. - Scripts use `local-env python sync` and the `DATABRICKS_LOCALENV_CONSTRAINT_SOURCE` override; goldens show the `local-env python sync` command field and managed marker. No source changes. ## Testing strategy - Goldens generated with `-update` and verified **stable on a clean re-run** (no `-update`); all 9 subtests pass. - `musterr` guards the five expected-failure scenarios; `trace` shows the three output-producing ones. - Full acceptance suite run to confirm no regressions elsewhere (only pre-existing, environment-specific failures unrelated to this change). - Diff confined to `acceptance/localenv/`. - Independently verified by a review subagent (PASS — goldens, scripts, stubs, stale-refs, hygiene) and by codex (no issues). --- ## About this stack This is one of a series of small, stacked PRs that together add the `databricks local-env python sync` command — it provisions a local Python environment (Python version, `databricks-connect` pin, and dependency constraints) matched to a selected Databricks compute target. The work was split from one large branch into single-concern layers so each is independently reviewable; the command is kept hidden until the final PR so nothing is user-visible mid-stack. **Review bottom-up.** Layers 1–5 have merged (the original layer-5 PR databricks#5828 was split into 5a/5b/5c during review). | # | PR | What | Status | |---|----|------|--------| | 1 | databricks#5823 | foundation: result types + env-key mapping | merged | | 2 | databricks#5824 | compute-target resolution | merged | | 3 | databricks#5826 | constraint fetch + offline cache | merged | | 4 | databricks#5827 | formatting-preserving pyproject.toml merge | merged | | 5a | databricks#5850 | package-manager interface + detection | merged | | 5b | databricks#5851 | six-phase pipeline orchestrator | merged | | 5c | databricks#5854 | --check cache purity, greenfield name, dbc insertion | merged | | 6 | databricks#5832 | uv backend + CLI command (registered hidden) | | | 7 | **databricks#5833 ← you are here** | acceptance tests | | | 8 | databricks#5835 | unveil (unhide + help + changelog) | | This pull request and its description were written by Isaac.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
[VPEX][5/8]) reads as +3,466 / 15 files on GitHub, but that is an artifact: PRs 1–4 were squash-merged intomainwhiledbconnect/05-pipelinestill sits on the pre-merge parent, so GitHub re-counts all of the already-merged code. The genuinely-new content in that layer is +1,165 / 5 files.PackageManagerinterface, manager detection, and the writability preflight — none of which reference the pipeline orchestrator.What
pkgmanager.go— thePackageManagerinterface the pipeline provisions through (implemented by the uv backend in a later PR).detect.go— uv-vs-not-uv detection (biased toward uv, whose native project file is thepyproject.tomlthis command drives), the non-blaming guidance message shown for an unsupported manager, and theensureWritablepreflight.pyprojectFileconstant moves here frompipeline.go, since detection is its first consumer.Testing strategy
detect_test.gocovers the detection matrix (greenfield, uv lock, plain pyproject, conda/pip precedence),ensureWritableon a writable and a non-existent dir, and the unsupported-manager guidance message.go build,go test,golangci-lint(0 issues),deadcode,gofmt— all green.About this stack
This is one of a series of small, stacked PRs that together add the
databricks local-env python synccommand. It supersedes the pipeline half of #5828, split further at the interface/detection seam. Review bottom-up.This PR and #5b (the six-phase pipeline orchestrator, stacked on this one) together replace #5828.
This pull request and its description were written by Isaac.